package example1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class GetLocalIpAddress {
    public static void main(String[] args) {
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            String hostAddress = inetAddress.getHostAddress();
            System.out.println("本机 IP 地址：" + hostAddress);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
